package com.sicpa.web.controller.system;

import com.sicpa.common.annotation.Log;
import com.sicpa.common.constant.Constants;
import com.sicpa.common.constant.UserConstants;
import com.sicpa.common.core.controller.BaseController;
import com.sicpa.common.core.domain.AjaxResult;
import com.sicpa.common.core.domain.entity.AntiCounterfeitingRegisteredOffice;
import com.sicpa.common.core.domain.entity.SysUser;
import com.sicpa.common.core.page.TableDataInfo;
import com.sicpa.common.core.redis.RedisCache;
import com.sicpa.common.enums.BusinessType;
import com.sicpa.common.enums.RoleEnum;
import com.sicpa.common.utils.SecurityUtils;
import com.sicpa.common.utils.StringUtils;
import com.sicpa.common.utils.file.FileUtils;
import com.sicpa.common.utils.poi.ExcelUtil;
import com.sicpa.system.service.IAntiCounterfeitingRegisteredOfficeService;
import com.sicpa.system.service.ICheckUserPowerService;
import com.sicpa.system.service.ISysUserService;
import com.sicpa.vo.OfficePowers;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * OfficeController
 *
 * @author lwf
 */
@Api(tags = "事务所管理")
@RestController
@RequestMapping("/office")
public class OfficeController extends BaseController {

    private IAntiCounterfeitingRegisteredOfficeService iAntiCounterfeitingRegisteredOfficeService;

    private ISysUserService userService;

    private RedisCache redisCache;

    private ICheckUserPowerService iCheckUserPowerService;

    @Autowired
    public OfficeController(IAntiCounterfeitingRegisteredOfficeService iAntiCounterfeitingRegisteredOfficeService, ISysUserService userService, ICheckUserPowerService iCheckUserPowerService, RedisCache redisCache) {
        this.iAntiCounterfeitingRegisteredOfficeService = iAntiCounterfeitingRegisteredOfficeService;
        this.userService = userService;
        this.iCheckUserPowerService = iCheckUserPowerService;
        this.redisCache = redisCache;
    }

    /**
     * 获取事务所列表
     *
     * @param office
     * @return
     */
    @GetMapping("/list")
    public TableDataInfo list(AntiCounterfeitingRegisteredOffice office) {
        SysUser user = SecurityUtils.getLoginUser().getUser();
        Integer isOfficeAccount = user.getIsOfficeAccount();
        List<AntiCounterfeitingRegisteredOffice> list;
        if (1 == isOfficeAccount) {
            startPage();
            list = iAntiCounterfeitingRegisteredOfficeService.puSelect(office);
        } else {
            if (iCheckUserPowerService.noAdminHashRole(RoleEnum.OFFICE_GROUPING_ADMIN.getRoleKey())) {
                List<String> officeIds = iAntiCounterfeitingRegisteredOfficeService.selectOfficeIdList();
                startPage();
                list = iAntiCounterfeitingRegisteredOfficeService.zuSelect(office, officeIds);
            } else {
                startPage();
                list = iAntiCounterfeitingRegisteredOfficeService.scipaSelect(office);
            }
        }
        return getDataTable(list);
    }

    /**
     * 根据事务所id获取事务所
     *
     * @param officeId
     * @return
     */
    @GetMapping(value = "/{officeId}")
    public AjaxResult get(@PathVariable(value = "officeId") Long officeId) {
        AntiCounterfeitingRegisteredOffice office = iAntiCounterfeitingRegisteredOfficeService.selectById(officeId);
        if (office == null) {
            return AjaxResult.error("没有此事务所");
        }
        boolean flag = iAntiCounterfeitingRegisteredOfficeService.isOfficeData(office) < 1;
        if (office != null && flag) {
            return AjaxResult.success("无权限");
        }
        SysUser user = SecurityUtils.getLoginUser().getUser();
        Integer isOfficeAccount = user.getIsOfficeAccount();
        if (1 == isOfficeAccount) {
            office.setOperator(user.getNickName());
            office.setOperatorNumber(user.getTelephone());
            office.setPhoneNumberOfOperator(user.getPhonenumber());
        }else{
            SysUser sysUser = new SysUser();
            sysUser.setOfficeId(officeId);
            List<SysUser> list = userService.selectOfficeUserList(sysUser);
            office.setOfficeUserList(list);
        }
        return AjaxResult.success(office);
    }
    /**
     * 添加事务所普通用户
     *
     * @param sysUser
     * @return
     */
    @PostMapping(value = "/addOfficeUser")
    public AjaxResult addOfficeUser(@RequestBody SysUser sysUser) {
        if (UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(sysUser))) {
            return AjaxResult.error("新增事务所用户'" + sysUser.getNickName() + "'失败，操作人手机号码已存在");
        }
        int flag = iAntiCounterfeitingRegisteredOfficeService.addOfficeUser(sysUser);
        if(flag == -1){
            return AjaxResult.error("新增事务所用户'" + sysUser.getNickName() + "'失败，操作人账号已存在");
        }else{
            return AjaxResult.success(flag);
        }

    }

    /**
     * 查询该事务所最大序号
     *
     * @param officeId
     * @return
     */
    @GetMapping(value = "/selectMaxSortOffice")
    public AjaxResult selectMaxSortOffice(@RequestParam("officeId") Long officeId) {
        AntiCounterfeitingRegisteredOffice office = iAntiCounterfeitingRegisteredOfficeService.selectById(officeId);
        if (office == null) {
            return AjaxResult.error("没有此事务所");
        }
        return AjaxResult.success(iAntiCounterfeitingRegisteredOfficeService.selectMaxSortOffice(office));
    }

    /**
     * 新增事务所
     *
     * @param office
     * @return
     */
    @Log(title = "新增事务所", businessType = BusinessType.INSERT)
    @PostMapping
    @PreAuthorize("@ss.hasPermi('office:add')")
    public AjaxResult add(@RequestBody AntiCounterfeitingRegisteredOffice office) {
        SysUser sysUser = new SysUser();
        sysUser.setPhonenumber(office.getPhoneNumberOfOperator());
        if (UserConstants.NOT_UNIQUE.equals(userService.checkOfficeUserNameUnique(office.getFirmName()))) {
            return AjaxResult.error("新增事务所'" + office.getFirmName() + "'失败，事务所名称已存在");
        } else if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(office.getPracticeCertificateNo()))) {
            return AjaxResult.error("新增事务所'" + office.getFirmName() + "'失败，事务所执业证书编号已存在");
        } else if (UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(sysUser))) {
            return AjaxResult.error("新增事务所'" + office.getFirmName() + "'失败，操作人手机号码已存在");
        }
        //注册会计师数量
        String numberOfCpas = office.getNumberOfCpas();
        Pattern pattern = Pattern.compile("[0-9]*");
        Matcher isNum = pattern.matcher(numberOfCpas);
        boolean matches = isNum.matches();
        if (!matches) {
            return AjaxResult.error("请填写正确的注册会计师数量");
        }
        //其中分所注师数量
        String numberOfBranchRegisteredEngineers = office.getNumberOfBranchRegisteredEngineers();
        if (StringUtils.isNotEmpty(numberOfBranchRegisteredEngineers)) {
            isNum = pattern.matcher(numberOfBranchRegisteredEngineers);
            matches = isNum.matches();
            if (!matches) {
                return AjaxResult.error("请填写正确的其中分所注师数量");
            }
        }
        //注册资本(万元)
        String registeredCapital = office.getRegisteredCapital();
        if (StringUtils.isNotEmpty(registeredCapital)) {
            pattern = Pattern.compile("([1-9]\\d*|0)(\\.\\d{2})?$");
            isNum = pattern.matcher(registeredCapital);
            matches = isNum.matches();
            if (!matches) {
                return AjaxResult.error("请填写正确的注册资本");
            }
        }
        //股东合伙人数
        String numberOfPartners = office.getNumberOfPartners();
        if (StringUtils.isNotEmpty(numberOfPartners)) {
            pattern = Pattern.compile("[0-9]*");
            isNum = pattern.matcher(numberOfPartners);
            matches = isNum.matches();
            if (!matches) {
                return AjaxResult.error("请填写正确的股东合伙人数");
            }
        }
        return AjaxResult.success(iAntiCounterfeitingRegisteredOfficeService.add(office));
    }

    /**
     * 外省事务所注册
     *
     * @param office
     * @return
     */
    @Log(title = "外省事务所注册", businessType = BusinessType.INSERT)
    @PostMapping("/register")
    public AjaxResult register(@RequestBody AntiCounterfeitingRegisteredOffice office) {
        String uuid = office.getUuid();
        if (Optional.ofNullable(uuid).isPresent()) {
            String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
            String existCode = redisCache.getCacheObject(verifyKey);
            if (!StringUtils.equals(office.getCode(), existCode)) {
                return AjaxResult.error("验证码错误!");
            }
        } else {
            return AjaxResult.error("违规操作!");
        }
        //审核状态  0：待审核，1：审核通过，-2：审核不通过，2：无需审核'
        office.setAuditStatus(0);
        //事务所系统状态,1:启用，2：停用,3：未启用,-1：删除'
        office.setStatus(3);
        //默认注册时全为外省市注册1
        office.setIsRegister(1);
        office.setFirmStatus("正常");
        SysUser sysUser = new SysUser();
        sysUser.setPhonenumber(office.getPhoneNumberOfOperator());
       /* if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(office.getOfficeNumber()))) {
            return AjaxResult.error("新增事务所'" + office.getPracticeCertificateNo() + "'失败，事务所编号已存在");
        } else if (UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(sysUser))) {
            return AjaxResult.error("新增事务所'" + office.getPracticeCertificateNo() + "'失败，操作人手机号码已存在");
        }*/
        if (UserConstants.NOT_UNIQUE.equals(userService.checkOfficeUserNameUnique(office.getFirmName()))) {
            return AjaxResult.error("新增事务所'" + office.getFirmName() + "'失败，事务所名称已存在");
        } else if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(office.getPracticeCertificateNo()))) {
            return AjaxResult.error("新增事务所'" + office.getFirmName() + "'失败，事务所执业证书编号已存在");
        }
        return AjaxResult.success(iAntiCounterfeitingRegisteredOfficeService.add(office));
    }

    /**
     * 修改事务所
     *
     * @param office
     * @return
     */
    @Log(title = "修改事务所", businessType = BusinessType.UPDATE)
    @PutMapping
    @PreAuthorize("@ss.hasPermi('office:edit')")
    public AjaxResult edit(@RequestBody AntiCounterfeitingRegisteredOffice office) {
        return iAntiCounterfeitingRegisteredOfficeService.edit(office);
    }

    /**
     * 修改账号有效期
     *
     * @param office
     * @return
     */
    @ApiOperation("修改账号有效期")
    @Log(title = "修改账号有效期", businessType = BusinessType.UPDATE)
    @PutMapping("/editValidity")
    @PreAuthorize("@ss.hasPermi('office:set:time')")
    public AjaxResult editValidity(@RequestBody AntiCounterfeitingRegisteredOffice office) {
        return AjaxResult.success(iAntiCounterfeitingRegisteredOfficeService.editValidity(office));
    }

    /**
     * 根据事务所 id 重置事务所账号密码
     * 停用
     * @param officeId
     * @return
     */
    @Log(title = "根据事务所 id 重置事务所账号密码", businessType = BusinessType.UPDATE)
    @GetMapping(value = "/resetPwd/{officeId}")
    @PreAuthorize("@ss.hasPermi('office:reset:pwd')")
    public AjaxResult resetOfficePwd(@PathVariable(value = "officeId") Long officeId) {
        return AjaxResult.success(iAntiCounterfeitingRegisteredOfficeService.resetPwdByOfficeId(officeId));
    }

    /**
     * 事务所导入
     *
     * @param file
     * @return
     * @throws Exception
     */
    @Log(title = "事务所导入", businessType = BusinessType.IMPORT)
    @PostMapping("/importOffice")
    @PreAuthorize("@ss.hasPermi('office:import')")
    public AjaxResult importOffice(@RequestParam("file") MultipartFile file) throws Exception {
        ExcelUtil<AntiCounterfeitingRegisteredOffice> util = new ExcelUtil<>(AntiCounterfeitingRegisteredOffice.class);
        List<AntiCounterfeitingRegisteredOffice> officeList = util.importExcel(file.getInputStream());
        if (!Optional.ofNullable(officeList).isPresent() || !Optional.ofNullable(officeList.get(0)).isPresent()) {
            return AjaxResult.error("表格数据错误!");
        }
        Map<String, Object> res = iAntiCounterfeitingRegisteredOfficeService.importOffice(officeList);
        return AjaxResult.success(res);
    }

    /**
     * 批量删除事务所,   状态为3,未启用的可以删除,其他的不能删除
     *
     * @param officeIds
     * @return
     * @author wph 20200907
     */
    @PreAuthorize("@ss.hasPermi('office:remove')")
    @Log(title = "批量删除事务所", businessType = BusinessType.DELETE)
    @ApiOperation("批量删除事务所")
    @ApiImplicitParam(name = "officeIds", value = "事务所id", dataType = "Long[]")
    @DeleteMapping("/{officeIds}")
    public AjaxResult deleteOffices(@PathVariable Long[] officeIds) {
        return AjaxResult.success(iAntiCounterfeitingRegisteredOfficeService.deleteOffices(officeIds));
    }

    /**
     * @param office 事务所实体
     * @author wph 20200907
     */
    @PreAuthorize("@ss.hasPermi('office:edit')")
    @Log(title = "修改事务所状态", businessType = BusinessType.UPDATE)
    @PutMapping("/updateStatus")
    @ApiOperation("修改事务所状态:1：恢复，2：终止")
    public AjaxResult updateStatus(@RequestBody AntiCounterfeitingRegisteredOffice office) {
        return AjaxResult.success(iAntiCounterfeitingRegisteredOfficeService.updateStatus(office.getOfficeId(), office.getStatus()));
    }

    /**
     * 事务所数据导出
     *
     * @param office
     * @return
     */
    @Log(title = "事务所数据导出", businessType = BusinessType.EXPORT)
    @GetMapping("/exportOffice")
    @PreAuthorize("@ss.hasPermi('office:export')")
    public AjaxResult exportOffice(AntiCounterfeitingRegisteredOffice office) {
        SysUser user = SecurityUtils.getLoginUser().getUser();
        Integer isOfficeAccount = user.getIsOfficeAccount();
        List<AntiCounterfeitingRegisteredOffice> list;
        if (1 == isOfficeAccount) {
            startPage();
            list = iAntiCounterfeitingRegisteredOfficeService.puSelect(office);
        } else {
            if (iCheckUserPowerService.noAdminHashRole(RoleEnum.OFFICE_GROUPING_ADMIN.getRoleKey())) {
                List<String> officeIds = iAntiCounterfeitingRegisteredOfficeService.selectOfficeIdList();
                startPage();
                list = iAntiCounterfeitingRegisteredOfficeService.zuSelect(office, officeIds);
            } else {
                startPage();
                list = iAntiCounterfeitingRegisteredOfficeService.scipaSelect(office);
            }
        }
        ExcelUtil<AntiCounterfeitingRegisteredOffice> util = new ExcelUtil<>(AntiCounterfeitingRegisteredOffice.class);
        return util.exportExcel(list, "事务所数据");
    }

    /**
     * 查询事务所权限配置列表
     *
     * @param office
     * @return
     */
    @ApiOperation("查询事务所权限配置列表")
    @GetMapping("/officePowersList")
    public TableDataInfo officePowersList(AntiCounterfeitingRegisteredOffice office) {
        List<Map<String, Object>> list;
        if (iCheckUserPowerService.noAdminHashRole(RoleEnum.OFFICE_GROUPING_ADMIN.getRoleKey())) {
            List<String> officeIds = iAntiCounterfeitingRegisteredOfficeService.selectOfficeIdList();
            if (Optional.ofNullable(officeIds).isPresent() && officeIds.size() > 0) {
                startPage();
                list = iAntiCounterfeitingRegisteredOfficeService.officeAdminSelect(office, officeIds);
            } else {
                list = new ArrayList<>();
            }
        } else {
            startPage();
            list = iAntiCounterfeitingRegisteredOfficeService.adminSelect(office);
        }
        TableDataInfo tableDataInfo = getDataTable(list);
        return iAntiCounterfeitingRegisteredOfficeService.officePowerDataHander(tableDataInfo, list);
    }

    /**
     * 审核事务所
     *
     * @param office 事务所实体
     * @return
     * @author wph 20200909
     */
    @PreAuthorize("@ss.hasPermi('office:examine:audit')")
    @Log(title = "审核事务所", businessType = BusinessType.UPDATE)
    @ApiOperation("审核事务所")
    @PostMapping("/auditOffice")
    public AjaxResult audit(@RequestBody AntiCounterfeitingRegisteredOffice office) {
        return AjaxResult.success(iAntiCounterfeitingRegisteredOfficeService.audit(office));
    }

    /**
     * 查询事务所审核列表
     *
     * @param firmName              事务所名称
     * @param practiceCertificateNo 事务所执业证书编号
     * @return TableDataInfo 待审核事务所列表
     * @author wph 20200909
     */
    @ApiOperation("查询事务所 审核 列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "firmName", value = "事务所名称", dataType = "String"),
            @ApiImplicitParam(name = "practiceCertificateNo", value = "事务所执业证书编号", dataType = "String"),
            @ApiImplicitParam(name = "auditStatus", value = "审核状态", dataType = "Integer")})
    @GetMapping("/listAudit")
    public TableDataInfo listAudit(String firmName, String practiceCertificateNo, Integer auditStatus) {
        startPage();
        List<Map<String, Object>> list = iAntiCounterfeitingRegisteredOfficeService.selectListAudit(firmName, practiceCertificateNo, auditStatus);
        return getDataTable(list);
    }

    /**
     * 加载事务所权限树结构
     *
     * @param officeId
     * @return
     */
    @GetMapping("/getOfficePowersByOfficeId/{officeId}")
    public AjaxResult getOfficePowersByOfficeId(@PathVariable(value = "officeId") Long officeId) {
        return AjaxResult.success(iAntiCounterfeitingRegisteredOfficeService.getOfficePowersByOfficeId(officeId));
    }

    /**
     * 保存事务所权限
     *
     * @param powers
     * @return
     */
    @Log(title = "保存事务所权限", businessType = BusinessType.INSERT)
    @PutMapping("/saveOfficePowers")
    @PreAuthorize("@ss.hasPermi('office:permission:edit')")
    public AjaxResult saveOfficePowers(@RequestBody OfficePowers powers) {
        iAntiCounterfeitingRegisteredOfficeService.saveOfficePowers(powers.getOfficeId(), powers.getPowerIds());
        return AjaxResult.success();
    }

    /**
     * 事务所导入业务数据模板下载
     *
     * @param request
     * @param response
     * @throws IOException
     */
    @GetMapping("/template/download")
    public void templateDown(HttpServletRequest request, HttpServletResponse response) throws IOException {
        // 本地资源路径
        response.setCharacterEncoding("utf-8");
        response.setContentType("multipart/form-data");
        response.setHeader("Content-Disposition",
                "attachment;fileName=" + FileUtils.setFileDownloadHeader(request, "事务所导入模板.xlsx"));
        ClassPathResource resource = new ClassPathResource("excel/office_import_data_template.xlsx");
        InputStream inputStream = resource.getInputStream();
        int b = 0;
        byte[] buffer = new byte[1024];
        ServletOutputStream out = response.getOutputStream();
        while ((b = inputStream.read(buffer)) != -1) {
            out.write(buffer, 0, b);
        }
        inputStream.close();
        if (out != null) {
            out.flush();
            out.close();
        }
    }

    /**
     * 事务所申请联系人模板下载
     *
     * @param request
     * @param response
     * @throws IOException
     */
    @GetMapping("/template/officeContact")
    public void templateDownofficeContact(HttpServletRequest request, HttpServletResponse response) throws IOException {
        // 本地资源路径
        response.setCharacterEncoding("utf-8");
        response.setContentType("multipart/form-data");
        response.setHeader("Content-Disposition",
                "attachment;fileName=" + FileUtils.setFileDownloadHeader(request, "防伪系统申请修改操作人.docx"));
        ClassPathResource resource = new ClassPathResource("excel/防伪系统申请修改操作人.docx");
        InputStream inputStream = resource.getInputStream();
        int b = 0;
        byte[] buffer = new byte[1024];
        ServletOutputStream out = response.getOutputStream();
        while ((b = inputStream.read(buffer)) != -1) {
            out.write(buffer, 0, b);
        }
        inputStream.close();
        if (out != null) {
            out.flush();
            out.close();
        }
    }

    /**
     * 事务所申请联系人模板下载
     *
     * @param request
     * @param response
     * @throws IOException
     */
    @GetMapping("/template/officeRegister")
    public void templateDownofficeRegister(HttpServletRequest request, HttpServletResponse response) throws IOException {
        // 本地资源路径
        response.setCharacterEncoding("utf-8");
        response.setContentType("multipart/form-data");
        response.setHeader("Content-Disposition",
                "attachment;fileName=" + FileUtils.setFileDownloadHeader(request, "申请材料清单.pdf"));
        ClassPathResource resource = new ClassPathResource("excel/申请材料清单.pdf");
        InputStream inputStream = resource.getInputStream();
        int b = 0;
        byte[] buffer = new byte[1024];
        ServletOutputStream out = response.getOutputStream();
        while ((b = inputStream.read(buffer)) != -1) {
            out.write(buffer, 0, b);
        }
        inputStream.close();
        if (out != null) {
            out.flush();
            out.close();
        }
    }

    /**
     * 事务所总所导入模板
     *
     * @param request
     * @param response
     * @throws IOException
     */
    @GetMapping("/officeTemplate/download")
    public void officeTemplateDown(HttpServletRequest request, HttpServletResponse response) throws IOException {
        // 本地资源路径
        response.setCharacterEncoding("utf-8");
        response.setContentType("multipart/form-data");
        response.setHeader("Content-Disposition",
                "attachment;fileName=" + FileUtils.setFileDownloadHeader(request, "事务所总所导入模板.xlsx"));
        ClassPathResource resource = new ClassPathResource("excel/事务所总所导入模板.xlsx");
        InputStream inputStream = resource.getInputStream();
        int b = 0;
        byte[] buffer = new byte[1024];
        ServletOutputStream out = response.getOutputStream();
        while ((b = inputStream.read(buffer)) != -1) {
            out.write(buffer, 0, b);
        }
        inputStream.close();
        if (out != null) {
            out.flush();
            out.close();
        }
    }

    /**
     * 事务所分所导入模板
     *
     * @param request
     * @param response
     * @throws IOException
     */
    @GetMapping("/officeBranchTemplate/download")
    public void officeBranchTemplateDown(HttpServletRequest request, HttpServletResponse response) throws IOException {
        // 本地资源路径
        response.setCharacterEncoding("utf-8");
        response.setContentType("multipart/form-data");
        response.setHeader("Content-Disposition",
                "attachment;fileName=" + FileUtils.setFileDownloadHeader(request, "事务所分所导入模板.xlsx"));
        ClassPathResource resource = new ClassPathResource("excel/事务所分所导入模板.xlsx");
        InputStream inputStream = resource.getInputStream();
        int b = 0;
        byte[] buffer = new byte[1024];
        ServletOutputStream out = response.getOutputStream();
        while ((b = inputStream.read(buffer)) != -1) {
            out.write(buffer, 0, b);
        }
        inputStream.close();
        if (out != null) {
            out.flush();
            out.close();
        }
    }

    /**
     * 根据事务所ID 获取审核事务所详情
     *
     * @param officeId 事务所id
     * @return
     * @author wph 20200911
     */
    @PreAuthorize("@ss.hasPermi('office:examine:detail')")
    @GetMapping("/getDetailById/{officeId}")
    @ApiOperation("根据事务所ID 获取审核事务所详情")
    @ApiImplicitParam(name = "officeId", value = "事务所id", dataType = "Long")
    public AjaxResult getDetailById(@PathVariable Long officeId) {
        AntiCounterfeitingRegisteredOffice office = iAntiCounterfeitingRegisteredOfficeService.getDetailByNumber(officeId);
        if (office == null) {
            return AjaxResult.error("没有此事务所");
        }
        if (office != null && iAntiCounterfeitingRegisteredOfficeService.isOfficeData(office) < 1) {
            return AjaxResult.success("无权限");
        }
        return AjaxResult.success(office);
    }

}
